package com.zhdl.modules.demo.web;

import com.zhdl.hardware.robot.beCurrent.repository.impl.FairDemoPortCmdHandleDaoImpl;
import com.zhdl.modules.tools.CommonCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class DemoProcess {
    /**
     * 线程管理
     */
    @Resource
    public ThreadPoolTaskScheduler taskScheduler1;

    @Resource
    private FairDemoPortCmdHandleDaoImpl fairDemoPortCmdHandleDao;

    public void init(){
        fairDemoPortCmdHandleDao.addPort("192.168.0.101:5055");

        taskScheduler1.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                fairDemoPortCmdHandleDao.FairRobotAction("192.168.0.101:5055", "0", new CommonCallback<String>() {
                    @Override
                    public void statusCallback(String s) {
                        log.info("s-------->" + s);
                    }
                });
            }
        }, 100);
    }
}
